
import { setApp } from '../../../../store/creatorSlice'
import leftList from '../../view-components/left'
import style from './style.module.css'
import { useDispatch } from 'react-redux'

function LeftApps () {
  const dispatch = useDispatch()
  function addApp (item) {
    dispatch(setApp({
      name: item.name,
      id: Math.random()*1000000
    }))
  }

  return (
    <div className={style['left-view']}>
      {
        leftList.map((item) => {
          let NewItem = item.render
          return <NewItem onClick={() => {addApp(item)}} key={item.name}/>
        })
      }
    </div>
  )
}

export default LeftApps